import request from "@/utils/request.js";

export const listUser = async () => {
    const res = await request.get('/user/list');
    return res.map(e => ({...e, value: e.id, label: e.nickname}))
}

export const businessTypeOptions = [
    {value: 1, label: '菜品', type: 'primary'},
    {value: 2, label: '旧物', type: 'info'},
    {value: 3, label: '任务', type: 'warning'},
]

export const fields = [
    {
        prop: 'userId',
        label: '评价用户',
        type: 'remote-select',
        api: listUser,
        width: 120,
    },
    {
        prop: 'businessId',
        label: '所属业务',
        type: 'number',
        width: 'auto',
    },
    {
        prop: 'businessType',
        label: '业务类型',
        type: 'tag',
        options: businessTypeOptions,
        search: true,
        width: 120,
    },
    {
        prop: 'rating',
        label: '评分',
        type: 'rating',
        width: 170,
    },
    {
        prop: 'content',
        label: '评价内容',
        type: 'longtext',
        width: '200',
    },
    {
        prop: 'createTime',
        label: '创建时间',
        type: 'datetime',
        formHidden: true,
        width: 190,
    }
]